﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once
#include "GcmpDatabaseInterface.h"
#include "GbmpQuickCast.h"
#include "IObject.h"
#include "ClassId.h"

namespace gcmp
{
    class ISerializationBehavior;
    class ICloneBehavior;

    /// \brief Db层数据的基类
    ///
    /// 希望能被框架Db层支持的类需要派生此基类，并实现GetClassGuid(), GetSerializationBehavior(), GetCloneBehavior()接口函数。
    /// 以获取序列化、反序列化能力，并获取平台对该派生类深拷贝、事务等的自动支持。
    class GCMP_DATABASE_INTERFACE_EXPORT IDbObject : public IObject
    {
        DEFINE_CAST_DERIVED(gcmp::IDbObject, gcmp::IObject);
    public:
        /// \brief 获取Class的唯一标识符
        ///
        /// \return Guid 返回Class的Guid
        virtual Guid GetClassGuid(void) const = 0;

        /// \brief 获取序列化接口
        ///
        /// \return ISerializationBehavior * 返回序列化接口
        virtual ISerializationBehavior * GetSerializationBehavior(void) const = 0;

        /// \brief 获取克隆接口
        ///
        /// \return ICloneBehavior * 返回克隆接口
        virtual ICloneBehavior * GetCloneBehavior(void) const = 0;

    public:
        /// \brief 获取ClassId
        ///
        /// \return gcmp::ClassId 返回ClassId
        static ClassId GetClassId(void) { return ClassId(); }

        /// \brief 析构函数
        virtual ~IDbObject(void) = 0;
    };
}

